<%@ page language="java" contentType="text/html; charset=UTF-8" 
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
	<%@ include file="header.jsp"%>
	<title>登录</title>
	<style>
		.window {
			width: 400px;
			position: absolute;
			margin-left: -200px;
			margin-top: -80px;
			top: 50%;
			left: 50%;
			display: block;
			z-index: 2000;
			background: #fff;
			padding: 20 0;
		}
	</style>
</head>
<body style="background: #f1f1f1;">
<div class="window">
	<fieldset class="layui-elem-field" style="margin: 10px;">
		<legend>登录</legend>
		<div class="layui-field-box">
			<form  id="formId" action="/user/login" method="post" class="layui-form layui-form-pane">
				<div class="layui-form-item">
					<label class="layui-form-label">账号：</label>
					<div class="layui-input-inline">
						<input type="text" name="name" class="layui-input" autocomplete="off"
						    lay-verify="required" placeholder="请输入账号"/>
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">密码：</label>
					<div class="layui-input-inline">
						<input type="password" name="password" class="layui-input" autocomplete="off"
    						lay-verify="required" placeholder="请输入密码"/>
					</div>
				</div>
				<%--<div class="layui-form-item">
					<label class="layui-form-label">验证码：</label>
					<div class="layui-input-inline">
						<input type="text" name="authCode" class="layui-input" autocomplete="off"
							   lay-verify="required" placeholder="请输入验证码"/>
					</div>
					<div class="layui-input-inline">
						<img id="imgCode" src="/auth/code" onclick="refreshCode()"/>
					</div>
				</div>--%>
				<div class="layui-form-item">
					<div class="layui-form-item">
						<!--<label class="layui-form-label"></label> -->
						<div class="layui-input-inline">
							<input type="submit" class="layui-btn" value="登录" />
							<input type="reset" class="layui-btn layui-btn-primary" value="重置" />
						</div>
					</div>
				</div>
				<input type="hidden" name="action" value="login" />
			</form>
		</div>
	</fieldset>
</div>
<script type="text/javascript">
	var layer = layui.layer;
	function refreshCode() {
		$('#imgCode').attr('src', '/auth/code?' + Math.random());
	}

	function submitForm() {
		$.post('/user/login',
				$('#formId').serialize(),
				function(jsonResult) {
					if (jsonResult.ok) {// 登录成功
						layer.msg(jsonResult.msg);
						// 跳转到首页
						location.href = '/';
					} else {
						layer.msg(jsonResult.msg);
					}
				},
				'json'
		);
	}
</script>
</body>

</html>